package com.assets.room.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.assets.room.dao.AllotDao;
import com.assets.room.dao.AllotdetailDao;
import com.assets.room.dao.AssetDao;
import com.assets.room.dao.CheckDao;
import com.assets.room.dao.CheckDataDao;
import com.assets.room.dao.DeptDao;
import com.assets.room.dao.PlaceDao;
import com.assets.room.dao.ReceivesDao;
import com.assets.room.dao.ReceivesDetailDao;
import com.assets.room.dao.ReceivesReapplyDao;
import com.assets.room.dao.ReturnsDao;
import com.assets.room.dao.ScrapDao;
import com.assets.room.dao.ScrapScrapdetailDao;
import com.assets.room.dao.TypeDao;
import com.assets.room.dao.UserDao;
import com.assets.room.dao.WorkerDao;
import com.assets.room.entity.Allot;
import com.assets.room.entity.Allotdetail;
import com.assets.room.entity.Asset;
import com.assets.room.entity.Check;
import com.assets.room.entity.CheckData;
import com.assets.room.entity.Dept;
import com.assets.room.entity.Place;
import com.assets.room.entity.Receives;
import com.assets.room.entity.ReceivesDetail;
import com.assets.room.entity.ReceivesReapply;
import com.assets.room.entity.Returns;
import com.assets.room.entity.Scrap;
import com.assets.room.entity.ScrapScrapdetail;
import com.assets.room.entity.Type;
import com.assets.room.entity.User;
import com.assets.room.entity.Worker;

@Database(entities = {Check.class, CheckData.class, Place.class,
                        Type.class, Asset.class, Dept.class,
                        User.class, Receives.class, ReceivesDetail.class,
                        ReceivesReapply.class, Returns.class, Scrap.class,
                        ScrapScrapdetail.class, Worker.class, Allot.class,
                        Allotdetail.class }, version = 1, exportSchema = false)
//@TypeConverters({Converters.class})
public abstract class MyDataBase extends RoomDatabase {

    private static final String DATABASE_NAME = "jjh_db";

    private static MyDataBase databaseInstance;

    public static synchronized MyDataBase init(Context context)
    {
        if(databaseInstance == null)
        {
            databaseInstance = Room
                    .databaseBuilder(context.getApplicationContext(), MyDataBase.class, DATABASE_NAME)
                    //是否允许在主线程上操作数据库，默认false。
                    .allowMainThreadQueries()
                    .build();
        }
        return databaseInstance;
    }


    public abstract CheckDao checkDao();

    public abstract AllotDao allotService();

    public abstract AllotdetailDao allotdetailService();

    public abstract WorkerDao workerService();

    public abstract ScrapDao scrapService();

    public abstract ScrapScrapdetailDao scrapScrapdetailService();

    public abstract ReturnsDao returnsDao();

    public abstract UserDao userDao();

    public abstract CheckDataDao checkDataDao();

    public abstract PlaceDao placeDao();

    public abstract TypeDao typeDao();

    public abstract DeptDao deptDao();

    public abstract AssetDao assetDao();

    public abstract ReceivesDao receivesDao();

    public abstract ReceivesDetailDao receivesDetailDao();

    public abstract ReceivesReapplyDao receivesReapplyDao();

}
